<include file="nav:headr"/>
<div class="container">
    <div class="row">
        <div style="height: 30px"></div>
        <div class="col-md-2">
            <include file="Content:sider"/>
        </div>
        <div class="col-md-10">
            <div class="page-header">
                <h4>سەھىپە باشقۇرۇش</h4>
            </div>
            <div class="btn-group" role="group" aria-label="...">
                <a href="{:U('Category/index')}" class="btn btn-default">بارلىق سەھىپىلەر</a>
                <a href="{:U('Category/add')}" class="btn btn-default">يېڭىدىن قوشۇش</a>
            </div>
            <br/>
            <br/>
            <table class="table table-bordered">
                <thead>
                <tr class="active">
                    <td width="30">cid</td>
                    <td width="60">تەرتىپ</td>
                    <td>سەھىپە نامى</td>
                    <td>ھالىتى</td>
                    <td>مەشغۇلات</td>
                </tr>
                </thead>
                <tbody>
                    <foreach name="categorys" item="c">
                        <tr>
                            <td>{$c['cid']}</td>
                            <td><input class="form-control" type="text" onchange="jacascript:changgesort(this,{$c['cid']});" value="{$c['sort']}"></td>
                            <td><if condition="$c['pid'] neq 0"><?php echo str_repeat('&nbsp;',$c['level']*10);?>┘─&nbsp;</if>{$c['cname']}</td>
                            <td>
                                <if condition="$c['status']">
                                    <span class="label label-success">ئوچۇق</span>
                                    <else/>
                                    <span class="label label-danger">تاقاق</span>
                                </if>
                            </td>
                            <td>
                                <a href="{:U('Category/edit',array('cid'=>$c['cid']))}" class="btn btn-success btn-sm">تەھرىرلەش</a>
                                <a href="javascript:deCategory({$c['cid']})" class="btn btn-danger btn-sm">ئۆچۈرۈش</a>
                            </td>
                        </tr>
                    </foreach>
                </tbody>
            </table>
        </div>
    </div>
</div>
<script type="text/javascript">
    //分类排序
    function changgesort(obj,cid) {
        var csort=$(obj).val();
        $.ajax({
            'url':"{:U('Category/changgeSort')}",
            'type':'POST',
            'dataType':'json',
            'data':{'cid':cid,'sort':csort},
            success:function (phpRetrnData) {
                if(phpRetrnData.status){
                    layer.msg(phpRetrnData.message,{'icon':6},function () {
                        window.location=location;
                    })
                }
            }
        })
    }
    //删除提示框
   function deCategory(cid) {
       //询问框
       layer.confirm('راستىنلا ئۆچۈرەمسىز？', {
           btn: ['ھەئە','ياق'] //按钮
       }, function(){
           $.ajax({
               'url':"{:U('Category/delete')}",
               'type':'POST',
               'dataType':'json',
               'data':{'cid':cid},
               success:function (phpRetrnData) {
                   if(phpRetrnData.status){
                       layer.msg(phpRetrnData.massage,{'icon':6},function () {
                           window.location=location;
                       })
                   }else {
                       layer.msg(phpRetrnData.massage,{'icon':5});
                   }
               }
           })
       });
   }
</script>
<include file="nav:footer" />